package com.hzqy.service.statistics;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.hzqy.persistence.dao.statistics.SilentUserDao;
import com.hzqy.service.core.GenericServiceBean;
import com.hzqy.web.vo.PmsUserVo;
import com.hzqy.web.vo.StatDataSilentUserVo;

@Service
public class SilentUserServiceBean extends GenericServiceBean<PmsUserVo, SilentUserDao, Integer>{
	private static final long serialVersionUID = 1L;
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	
	@Resource
	private SilentUserDao silentUserDao;
	
	@Override
	public SilentUserDao getEntityDao() {
		return silentUserDao;
	}
	

	public Map<String, Object> selectSilentUserList(StatDataSilentUserVo statDataSilentUserVo, int curPage, int pageSize) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = silentUserDao.selectSilentUserCount(statDataSilentUserVo);
		map.put("total", rowCount);
		if(rowCount > 0 && curPage > 0 && pageSize > 0) {
			map.put("firstResult", (curPage-1)*pageSize);
			map.put("maxResults", pageSize);
			map.put("f_sdsu_type", statDataSilentUserVo.getF_sdsu_type());
			map.put("f_sdsu_areaid", statDataSilentUserVo.getF_sdsu_areaid());
			map.put("f_sdsu_status", statDataSilentUserVo.getF_sdsu_status());
			map.put("beginDate", statDataSilentUserVo.getBeginDate());
			map.put("endDate", statDataSilentUserVo.getEndDate());
			map.put("monthDate", statDataSilentUserVo.getMonthDate());
			map.put("weekDate", statDataSilentUserVo.getWeekDate());
			List<StatDataSilentUserVo> results = silentUserDao.selectSilentUserList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<StatDataSilentUserVo>());
		}
		return map;
	}
	
	public Map<String,Object> selectExcelList(StatDataSilentUserVo statDataSilentUserVo) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = silentUserDao.selectSilentUserCount(statDataSilentUserVo);
		map.put("total", rowCount);
		if(rowCount > 0) {
			map.put("f_sdsu_type", statDataSilentUserVo.getF_sdsu_type());
			map.put("f_sdsu_areaid", statDataSilentUserVo.getF_sdsu_areaid());
			map.put("f_sdsu_status", statDataSilentUserVo.getF_sdsu_status());
			map.put("beginDate", statDataSilentUserVo.getBeginDate());
			map.put("endDate", statDataSilentUserVo.getEndDate());
			map.put("monthDate", statDataSilentUserVo.getMonthDate());
			map.put("weekDate", statDataSilentUserVo.getWeekDate());
			List<StatDataSilentUserVo> results = silentUserDao.selectSilentUserExcelList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<StatDataSilentUserVo>());
		}
		return map;
	}


	public int insertUserList(List<StatDataSilentUserVo> insertUserList) {
		return silentUserDao.insertUserList(insertUserList);
	}
	
}
